/* 公共底部导航 */
function fixBottomNav(name='home') {
  //创建div
  const div = document.createElement("div");

  //添加类名
  div.className = `nav`;

  //添加HTML内容
  div.innerHTML = `
  <a class="nav-list ${name === "home" ? "active" : ""}" href="./home.html">
    <i class="iconfont icon-home"></i>
    <span>首页</span>
  </a>
  <a class="nav-list ${
    name === "running" ? "active" : ""
  }" href="./running.html">
    <i class="iconfont icon-dumbbell"></i>
    <span>运动</span>
  </a>
  <a class="nav-list ${name === "circle" ? "active" : ""}" href="./circle.html">
    <i class="iconfont icon-circle2"></i>
    <span>圈子</span>
  </a>
  <a class="nav-list ${name === "mine" ? "active" : ""}" href="./mine.html">
    <i class="iconfont icon-home2"></i>
    <span>我的</span>
  </a>
  `;

  //将div追加到body中
  document.body.append(div);
}

/* 运动头部导航 */
function soprtTopNav(name='running'){
  //创建节点
  const div=document.createElement('div')
  //添加类名
  div.className=`tabs-title dpflex`

  div.innerHTML=`
        <a href="./running.html" class="${name === "running" ? "active" : ""}">跑步</a>
        <a href="./biking.html" class="${name === "biking" ? "active" : ""}">骑行</a>
        <a href="./curse.html" class="${name === "curse" ? "active" : ""}">课程训练</a>
  `
 //将div追加到body中
 document.body.prepend(div);
}

/* 圈子头部导航 */
function circleTopNav(name){
  //创建节点
  const div=document.createElement('div')
  //添加类名
  div.className=`tabs-title dpflex`

  div.innerHTML=`
    <p class="dpflex">
        <a href="./circle.html" class="${name === "circle" ? "active" : ""}">关注</a>
        <a href="./nearby.html" class="${name === "nearby" ? "active" : ""}">附近</a>
        <a href="./collect.html" class="${name === "collect" ? "active" : ""}">收藏</a>
        <a href="#">个人动态</a>
    </p>
    <button class="add">添加+</button>
  `
   //将div追加到body中
 document.body.prepend(div);
}

/* 圈子动态添加跳转页面 */
function setDynamic(){
  /* 获取元素 */
let add=document.querySelector('.add')

/* 点击添加按钮，跳转页面 */
add.addEventListener('click',function(){
  location.href='./dynamic.html'
})
}


//导出对象
module.exports = {
  fixBottomNav,
  soprtTopNav,
  circleTopNav,
  setDynamic
};
